package net.wanho.controller;

import lombok.RequiredArgsConstructor;
import net.wanho.R.R;
import net.wanho.po.Unit;
import net.wanho.service.UnitService;
import net.wanho.vo.PageInfo;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 这个类是：
 *
 * @author: MENG HU WANG
 * @date: 2025/2/5 13:50
 * @version: 1.0
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("unit")
public class UnitController {
    private final UnitService unitService;


    // 查询所有单位列表
    @GetMapping("unit-list")
    public R unitList() {
        return R.ok(unitService.list());
    }

    // 分页查询所有单位列表
    @GetMapping("unit-page-list")
    public R supplyList(@RequestParam(required = false, defaultValue = "1") int pageNum,
                        @RequestParam(required = false, defaultValue = "5") int pageSize,
                        Unit unit) {
        PageInfo<Unit> list = unitService.getSupplyPage(pageNum, pageSize, unit);
        return R.ok(list);
    }
}

